package org.casaca.checkbackup.core.checksum;

import java.util.ArrayList;
import java.util.List;

import org.casaca.checkbackup.core.exception.ChecksumResetException;

public class ChecksumGroup {

	private long id;
	private String name;
	
	private List<Checksum> checksums;
	
	private static synchronized long getIdGroup(){
		return System.currentTimeMillis();
	}
	
	public ChecksumGroup(String name){
		this.id = getIdGroup();
		this.name = name;
		
		this.checksums = new ArrayList<Checksum>();
	}
	
	public long getId(){
		return this.id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Checksum> getChecksums() {
		return checksums;
	}
	
	public void addSlice(byte[] b, int offset, int len){
		for (Checksum c : this.checksums)
			c.addSlice(b, offset, len);
	}
	
	public void complete(){
		for (Checksum c : this.checksums)
			c.complete();
	}
	
	public void reset() throws ChecksumResetException{
		for (Checksum c : this.checksums)
			c.reset();
	}
}